package com.first.wchat.widget;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.first.wchat.R;
import com.wchat.network.device.Device;

public class DeviceAdapter extends BaseAdapter {

	ArrayList<Device> devices;
	Context mCtx;
	public DeviceAdapter(Context ctx,ArrayList<Device> devices) {
		mCtx = ctx;
		this.devices = devices;
	}

	@Override
	public int getCount() {
		return devices.size();
	}

	@Override
	public Object getItem(int position) {
		return devices.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View contentView, ViewGroup parent) {
		TextView tv = (TextView) View.inflate(mCtx, R.layout.testtv, null);
		Device device = (Device) getItem(position);
		tv.setText("[" + device.getAddress() + "] " + device.getName());
		return tv;
	}

}